import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Description
 * @author Jerry
 * @date 2016-08-08
 */

public class MyServlet extends HttpServlet {

/**
 14      * The doGet method of the servlet. <br>
 15      *
 16      * This method is called when a form has its tag value method equals to get.
 17      *
 18      * @param request the request send by the client to the server
 19      * @param response the response send by the server to the client
 20      * @throws ServletException if an error occurred
 21      * @throws IOException if an error occurred
 22      */
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                 throws ServletException, IOException {

                 response.setContentType("text/html");
                 PrintWriter out = response.getWriter();
                 out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
                 out.println("<HTML>");
                 out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
                 out.println("  <BODY>");
                 out.print("    This is ");
                 out.print(this.getClass());
                 out.println(", using the GET method");
                 out.println("  </BODY>");
                 out.println("</HTML>");
                 out.flush();
                out.close();
            }
                 /**
     42      * The doPost method of the servlet. <br>
     43      *
     44      * This method is called when a form has its tag value method equals to post.
     45      *
     46      * @param request the request send by the client to the server
     47      * @param response the response send by the server to the client
     48      * @throws ServletException if an error occurred
     49      * @throws IOException if an error occurred
     50      */
               public void doPost(HttpServletRequest request, HttpServletResponse response)
               throws ServletException, IOException {
                   response. setContentType("text/html");
               PrintWriter out = response.getWriter();
                out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
                out.println("<HTML>");
                out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
                out.println("  <BODY>");
              out.print("    This is ");
               out.print(this.getClass());
                out.println(", using the POST method");
               out.println("  </BODY>");
        out.println("</HTML>");
                out.flush();
               out.close();
           }

}
